//
//  main.m
//  递归04
//
//  Created by szcq on 2021/4/14.
//

#import <Foundation/Foundation.h>
int sumOuShu(int n);
int sumjiShu(int n);
int main(int argc, const char * argv[]) {
//    求输入100以内偶数和
    int resutlt = sumOuShu(100);//2550

    int resutlt1 = sumjiShu(9);//2500
    printf("result = %d\nresult1 = %d\n",resutlt,resutlt1);
    return 0;
}

int sumjiShu(int n) {
    int result = 0;
    if (n < 3) {
        result = 1;
    } else {
        int step = sumjiShu(n - 2);
        result = step + n;
    }
    return result;
}

int sumOuShu(int n) {
    int result = 0;
    if (n < 2) {
        result = 0;
    } else {
        int step = sumOuShu(n - 2);
        result = step + n;
    }
    return result;
}
